package com.joycom.cicddemo.controller;

import cn.hutool.json.JSONObject;
import com.joycom.cicddemo.ApiService;
import com.joycom.cicddemo.model.ResultData;
import jakarta.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author itmei
 * @Date 2023/12/20 20:33
 * @description: 控制层
 * @Title: ApiController
 * @Package com.itmei.cicddemo.demos.controller
 */
@RestController
@RequestMapping("/api")
public class ApiController {

    private static final Logger log = LoggerFactory.getLogger(ApiController.class);

    @Resource
    private ApiService apiService;

    /**
     *
     * @return
     */
    @GetMapping("/cityWeatherDetails")
    public ResultData cityWeatherDetails(String city) {
        String javaVersion = System.getProperty("java.version");
        log.info("++++++++++++当前JDK版本： " + javaVersion);
        JSONObject realWeather = apiService.getRealWeather(city);
        realWeather.set("jdk-version", javaVersion);
        return ResultData.success(realWeather);
    }
}


